﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Castle.Windsor;

namespace Test.Diploma.UI.Web.MVC.Code.Common
{
    public class AppDependencyResolver : IDependencyResolver
    {
        #region Fields

        private readonly IWindsorContainer _container;

        #endregion

        #region Constructors

        public AppDependencyResolver(IWindsorContainer windsorContainer)
        {
            this._container = windsorContainer;
        }

        #endregion

        #region IDependencyResolver Members

        public object GetService(Type serviceType)
        {
            return this._container.GetService(serviceType);
        }

        public IEnumerable<object> GetServices(Type serviceType)
        {
            return this._container.ResolveAll(serviceType).Cast<object>();
        }

        #endregion
    }
}